package com.danieldura.highrise.requests
{
	import com.danieldura.highrise.HighriseCredentials;
	import com.danieldura.highrise.data.Case;
	
	import flash.net.URLRequestMethod;
	
	public class CasesRequest extends HighriseRequest
	{
		public function CasesRequest( credentials:HighriseCredentials ):void
		{
			super( credentials, new HighriseRequestDataMap( "kase", "kases", Case ) );
		}
		
		public function show( id:int ):HighriseRequestToken
		{
			requestMethod = URLRequestMethod.GET;
			location = "/kases/" + id + format;
			return send();
		}
		
		public function listOpen():HighriseRequestToken
		{
			requestMethod = URLRequestMethod.GET;
			location = "/kases/open" + format;
			return send();
		}
		
		public function listClosed():HighriseRequestToken
		{
			requestMethod = URLRequestMethod.GET;
			location = "/kases/closed" + format;
			return send();
		}
		
		public function create( kase:Case ):HighriseRequestToken
		{
			requestMethod = URLRequestMethod.POST;
			location = "/kases.xml";
			requestData = kase.toXMLString();
			return send();
		}
		
		public function update( kase:Case ):HighriseRequestToken
		{
			requestMethod = "PUT";
			location = "/kases/" + kase.id + ".xml";
			requestData = kase.toXMLString();
			return send();
		}
		
		public function destroy( kase:Case ):HighriseRequestToken
		{
			requestMethod = "DELETE";
			location = "kases/" + kase.id + ".xml";
			return send();
		}

	}
}